﻿using AfrikDotnetWebSite.Models;
using System;
using System.Linq;

namespace AfrikDotnetWebSite.Helpers
{
    public class ProjectHelper
    {
        static Random random = new Random();

        public static Project GetRandomProject()
        {
            using (AfrikDotnetContext db = new AfrikDotnetContext())
            {
                var projects = db.Projects.ToList();
                if (projects.Count() == 0)
                {
                    return null;
                }
                int index = random.Next(projects.Count());
                var project = projects[index];
                return project;
            }
        }
    }
}